<template>
  <el-tabs v-model="activeName" class="demo-tabs">
    <el-tab-pane label="老师" name="first">
              
      <div class="col-lg-12 grid-margin stretch-card">
              <div class="card">
                <div class="card-body">
                  <h4 class="card-title">软件学院老师列表</h4>
                  <div class="table-responsive pt-3">
                    <table class="table table-bordered">
                      <thead>
                        <tr>
                          <th>
                            序号
                          </th>
                          <th>
                            姓名
                          </th>
                          <th>
                            性别
                          </th>
                          <th>
                            系别
                          </th>
                          <th>
                            电话
                          </th>
                          <th style="width: 41%;">
                            所授课程
                          </th>
                          <th style="width: 13%;">
                            操作
                          </th>
                        </tr>
                      </thead>
                      <tbody>
                        <tr v-for="(item,index) in teacherList" :key="index">
                          <td>
                            {{ index+1 }}
                          </td>
                          <td>
                            {{ item.teacher_name }}
                          </td>
                          <td>
                            {{ item.teacher_sex }}
                          </td>
                          <td>
                           {{ item.department }}
                          </td>
                          <td>
                            {{ item.phone }}
                          </td>
                          <td style="width: 41%;">
                            {{ item.courses }}
                          </td>
                          <td style="width: 13%;">
    <el-button type="button" v-if="user_id!==item.teacher_id"  @click="getChatWindow(item.teacher_id,item.teacher_name)" class="btn btn-outline-primary btn-fw w-100">发送消息</el-button>
    <el-dialog v-model="dialogMessage[item.teacher_name]" :title="item.teacher_name" width="500">
       <div style="height: 500px;">
        <div class="h-3/4 overflow-auto border-y border-black"> 
          <div class="container">
              <ul>
                  <li v-for="(item1,index1) in messageList[item.teacher_name]" :key="index1">
                  <div class="row">
                    <div class="col-sm-12 my-2">
                        <p class="text-center mb-2">{{ item1.send_time }}</p>
                        <div :class="isSelf(item1.sender_id)">
                          <div class="col-2 col-sm-2 d-flex justify-content-center">
                            <el-avatar class="text-black bg-blue-300">{{ item1.sender_name }}</el-avatar>
                          </div>
                          <div class="d-flex align-items-center col-auto border rounded max-w-80">
                          <p class="m-0 mx-2">{{ item1.content }}</p>
                          </div>
                          </div>
                    </div>
                </div>
                  </li>
              </ul>
            </div>
        </div>
        <div class="flex h-1/4 justify-content-end rounded-bottom">
          <textarea  @keyup.enter="sendMessageToService(item.teacher_id,item.teacher_name)" class="flex form-control p-0" id="exampleFormControlTextarea1" v-model="inputMessage" rows="2"></textarea>
          <button type="button" @click="sendMessageToService(item.teacher_id,item.teacher_name)" class="btn btn-outline-primary align-self-end m-3" style="position: absolute;">发送</button>
          <button type="button" @click="setDialog(item.teacher_name)" class="btn btn-outline-primary align-self-end my-3 mx-19" style="position: absolute;">退出</button>
        </div>
       </div>
     </el-dialog>
                          </td>
                        </tr>
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
            </div>



    </el-tab-pane>
    <el-tab-pane label="学生" name="second">
      <div class="col-lg-12 grid-margin stretch-card">
              <div class="card">
                <div class="card-body">
                  <h4 class="card-title">软件学院学生列表</h4>
                  <div class="table-responsive pt-3">
                    <table id="recent-purchases-listing" class="table dataTable no-footer" role="grid">
                      <thead>
                        <tr role="row">
                          <th class="sorting_asc" tabindex="0" aria-controls="recent-purchases-listing" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Name: activate to sort column descending" style="width: 104.366px;">姓名</th>
                          <th class="sorting" tabindex="0" aria-controls="recent-purchases-listing" rowspan="1" colspan="1" aria-label="Status report: activate to sort column ascending" style="width:67.6607px">性别</th>
                          <th class="sorting" tabindex="0" aria-controls="recent-purchases-listing" rowspan="1" colspan="1" aria-label="Office: activate to sort column ascending" style="width: 160.929px;">专业</th>
                          <th class="sorting" tabindex="0" aria-controls="recent-purchases-listing" rowspan="1" colspan="1" aria-label="Price: activate to sort column ascending" style="width:180.116px;">兴趣爱好</th>
                          <th class="sorting" tabindex="0" aria-controls="recent-purchases-listing" rowspan="1" colspan="1" aria-label="Date: activate to sort column ascending" style="width: 153.188px;">科研经历</th>
                          <th class="sorting" tabindex="0" aria-controls="recent-purchases-listing" rowspan="1" colspan="1" aria-label="Gross amount: activate to sort column ascending" style="width: 155.188px;">操作</th>
                        </tr>
                      </thead>
                      <tbody>
                      <tr role="row" class="odd" v-for="(student,stuIndex) in studentList" :key="stuIndex">
                            <td class="sorting_1">{{ student.student_name }}</td>
                            <td>{{ student.student_sex }}</td>
                            <td>{{ student.major }}</td>
                            <td>{{ student.interest }}</td>
                            <td>{{ student.search_exper }}</td>
                            <td>
                              <el-button v-if="user_id!==student.student_id" type="button"  @click="getChatWindStu(student.student_id,student.student_name)" class="btn btn-outline-primary btn-fw w-100">发送消息</el-button>
    <el-dialog v-model="dialogMessageStu[student.student_name]" :title="student.student_name" width="500">
       <div style="height: 500px;">
        <div class="h-3/4 overflow-auto border-y border-black"> 
          <div class="container">
              <ul class="px-0">
                  <li v-for="(stuitem1,stuindex1) in messageList[student.student_name]" :key="stuindex1">
                  <div class="row">
                    <div class="col-sm-12 my-2">
                        <p class="text-center mb-2">{{ stuitem1.send_time }}</p>
                        <div :class="isSelf(stuitem1.sender_id)">
                          <div class="col-2 col-sm-2 d-flex justify-content-center">
                            <el-avatar class="text-black bg-blue-300">{{ stuitem1.sender_name }}</el-avatar>
                          </div>
                          <div class="d-flex align-items-center col-auto border rounded max-w-80">
                          <p class="m-0 mx-2">{{ stuitem1.content }}</p>
                          </div>
                          </div>
                    </div>
                </div>
                  </li>
              </ul>
            </div>
        </div>
        <div class="flex h-1/4 justify-content-end rounded-bottom">
          <textarea  @keyup.enter="sendMessageToService(student.student_id,student.student_name)" class="flex form-control p-0" id="exampleFormControlTextarea1" v-model="inputMessage" rows="2"></textarea>
          <button type="button" @click="sendMessageToService(student.student_id,student.student_name)" class="btn btn-outline-primary align-self-end m-3" style="position: absolute;">发送</button>
          <button type="button" @click="setDialogStu(student.student_name)" class="btn btn-outline-primary align-self-end my-3 mx-19" style="position: absolute;">退出</button>
        </div>
       </div>
     </el-dialog>
                            </td>
                        </tr>
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
            </div>
    </el-tab-pane>
    
    <el-tab-pane label="科创项目" name="third">
      <button @click="drawer=true" class="btn btn-outline-primary">我管理的科创</button>
      <button @click="dialogFormVisible=true" class="btn btn-outline-primary">新增科创</button>

      <el-dialog v-model="dialogFormVisible" title="新增科创项目" width="500">
    <el-form :model="project">
      <el-form-item label="项目名称" :label-width="formLabelWidth">
        <el-input v-model="project.project_name" autocomplete="off" />
      </el-form-item>
      <el-form-item label="项目类型" :label-width="formLabelWidth">
      <el-select v-model="project.project_type" placeholder="请选择">
        <el-option label="竞赛" value="竞赛" />
        <el-option label="科研项目" value="科研项目" />
        <el-option label="大创" value="大创" />
      </el-select>
    </el-form-item>
      <el-form-item label="开始时间">
      <el-col :span="11">
        <el-date-picker
          type=date
          value-format="YYYY/MM/DD"
          v-model="startTime.date1"
          placeholder="Pick a date"
          style="width: 100%"
        />
      </el-col>
      <el-col :span="2" class="text-center">
        <span class="text-gray-500">-</span>
      </el-col>
      <el-col :span="11">
        <el-time-picker
          v-model="startTime.date2"
          value-format="HH:mm:ss"
          placeholder="Pick a time"
          style="width: 100%"
        />
      </el-col>
    </el-form-item>
    <el-form-item label="结束时间">
      <el-col :span="11">
        <el-date-picker
          type=date
          value-format="YYYY/MM/DD"
          v-model="endTime.date1"
          placeholder="Pick a date"
          style="width: 100%"
        />
      </el-col>
      <el-col :span="2" class="text-center">
        <span class="text-gray-500">-</span>
      </el-col>
      <el-col :span="11">
        <el-time-picker
          v-model="endTime.date2"
          value-format="HH:mm:ss"
          placeholder="Pick a time"
          style="width: 100%"
        />
      </el-col>
    </el-form-item>
    <el-form-item label="简单介绍" :label-width="formLabelWidth">
        <el-input type="textarea" v-model="project.introduce" autocomplete="off" />
    </el-form-item>
    <el-form-item label="人数" :label-width="formLabelWidth">
        <el-input type="number" v-model="project.all_number" autocomplete="off" />
    </el-form-item>
    <el-form-item label="要求" :label-width="formLabelWidth">
      <el-input type="textarea" v-model="project.requirement" autocomplete="off" />
    </el-form-item>

    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取消</el-button>
        <el-button type="primary" @click="addProject()">
          提交
        </el-button>
      </div>
    </template>
  </el-dialog>


      <el-drawer v-model="drawer" title="I am the title" size="70%" direction="btt" :with-header="false">
        <div class="container h-100 ">
          <div class="row h-100 ">
            <div class="col-4 h-100 border-r">
              <span style="margin-left: 30%;margin-bottom: 3px;">管理的科创信息列表</span>
              <table class="table table-hover">
                <thead v-if="teacherAdminProjects">
                  <tr>
                    <th scope="col">#</th>
                    <th scope="col">科创项目</th>
                    <th scope="col">开始时间</th>
                    <th scope="col">结束时间</th>
                    <th scope="col">类型</th>
                  </tr>
                </thead>
                <tbody>
                  <tr v-for="(item,index) in teacherAdminProjects" :key="index" @click="getApplicationByProjectID(item.project_id,item.project_name)">
                    <th scope="row">{{ index+1 }}</th>
                    <td>{{ item.project_name }}</td>
                    <td>{{ item.start_time.substr(0,10) }}</td>
                    <td>{{ item.end_time.substr(0,10) }}</td>
                    <td>{{ item.project_type }}</td>
                  </tr>
                </tbody>
              </table>
            </div>
            <div class="col">
             <div class="buttons">
              <button type="button" @click="getHaveJoinList()" class="btn btn-outline-primary">已加入</button>
              <button type="button" @click="getApplyList()" class="btn btn-outline-primary ml-1">申请中</button>
              <h3 style="display: inline; margin-left: 20%;">{{projectName}}</h3>
              <button class="btn btn-outline-danger" style="float: right;" @click="deleteProject(project_id)">结束</button>
             </div>
             <div>
              <table class="table table-hover mt-3">  
                  <thead v-if="applicationList">
                    <tr>
                      <th scope="col">#</th>
                      <th scope="col">学生姓名</th>
                      <th scope="col">申请时间</th>
                      <th scope="col">状态</th>
                      <th scope="col">操作</th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr v-for="(item,index) in showApplicationList" :key="index">
                      <th scope="row">{{ index+1 }}</th>
                      <td>{{ item.student_name }}</td>
                      <td>{{ item.apply_time }}</td>
                      <td>{{ item.apply_state }}</td>
                      <td>
                        <button @click="getStudentInfoByStudentID(item.student_id)" class="btn btn-outline-primary mr-1">查看学生信息</button>
                        <button v-if="item.apply_state!=='同意'" @click="updateApplyState(item.projectapply_id,project_id)" class="btn btn-outline-primary">批准</button>
                        <button v-if="item.apply_state=='同意'" class="btn btn-outline-primary"  @click="getChatWindPro(item.student_id,item.student_name)">发送消息</button>

                        <el-dialog v-model="dialogProStu[item.student_name]" :title="item.student_name" width="500">
       <div style="height: 500px;">
        <div class="h-3/4 overflow-auto border-y border-black"> 
          <div class="container">
              <ul class="px-0">
                  <li v-for="(stuitem1,stuindex1) in messageList[item.student_name]" :key="stuindex1">
                  <div class="row">
                    <div class="col-sm-12 my-2">
                        <p class="text-center mb-2">{{ stuitem1.send_time }}</p>
                        <div :class="isSelf(stuitem1.sender_id)">
                          <div class="col-2 col-sm-2 d-flex justify-content-center">
                            <el-avatar class="text-black bg-blue-300">{{ stuitem1.sender_name }}</el-avatar>
                          </div>
                          <div class="d-flex align-items-center col-auto border rounded max-w-80">
                          <p class="m-0 mx-2">{{ stuitem1.content }}</p>
                          </div>
                          </div>
                    </div>
                </div>
                  </li>
              </ul>
            </div>
        </div>
        <div class="flex h-1/4 justify-content-end rounded-bottom">
          <textarea @keyup.enter="sendMessageToService(item.student_id,item.student_name)" class="flex form-control p-0" id="exampleFormControlTextarea1" v-model="inputMessage" rows="2"></textarea>
          <button type="button" @click="sendMessageToService(item.student_id,item.student_name)" class="btn btn-outline-primary align-self-end m-3" style="position: absolute;">发送</button>
          <button type="button" @click="setDialogPro(item.student_name)" class="btn btn-outline-primary align-self-end my-3 mx-19" style="position: absolute;">退出</button>
        </div>
       </div>
     </el-dialog>



                      </td>
                      <el-dialog v-model="studentInfoShow" top="1em">

                        <div class="container w-75">
                          <h3 class="text-center">学生基本信息</h3><br>
                          <div class="flex flex-wrap gap-4">
                            <el-card style="width: 480px" @click="updateInfo('student_name','姓名')" shadow="never">姓名：{{ student.student_name }}</el-card>
                            <el-card style="width: 480px" @click="updateInfo('student_sex','性别')" shadow="never">性别：{{ student.student_sex }}</el-card>
                            <el-card style="width: 480px" @click="updateInfo('college','学院')" shadow="never">学院：{{ student.college }}</el-card>
                            <el-card style="width: 480px" @click="updateInfo('major','专业')" shadow="never">专业：{{ student.major}}</el-card>
                            <el-card style="width: 480px" @click="updateInfo('interest','兴趣爱好')" shadow="never">兴趣爱好：{{ student.interest }}</el-card>
                            <el-card style="width: 480px" @click="updateInfo('search_exper','科研经历')" shadow="never">科研经历：{{ student.search_exper }}</el-card>
                          </div>
                          <button @click="studentInfoShow=false" class="my-4 btn btn-outline-primary w-100">退出</button>
                        </div>
                       


                      </el-dialog>
                    </tr>
                  </tbody>
                </table>
             </div>
            </div>
          </div>
        </div>
      </el-drawer>

      <el-carousel :interval="4000" type="card" height="400px">
        <el-carousel-item  v-for="(item,index) in projectList" :key="index">
          <div class="card w-100 h-100">
              <h3>{{ item.project_name }}</h3>
              <div class="mx-3">
                <p class="lead" style="font-size: 1em;">&nbsp;&nbsp; {{ item.introduce }}</p>
              </div>
              <div class="mx-3">
                <p style="font-size: 1em"><B>时间:</B>&nbsp;&nbsp; {{ item.start_time }}~{{ item.end_time }}</p>
                <i class="mr-5" style="font-size: 1em"><B>类别:</B>&nbsp;&nbsp;{{ item.project_type }}</i>
                <i style="font-size: 1em"><B>管理员:</B>&nbsp;&nbsp;{{ item.admin_name }}</i>
                <p class="mt-3"><B>要求：</B>{{ item.requirement }}</p>
              </div>
              <div class="demo-progress ml-4">
                <p><b>目前人数：</b>{{ item.exist_number }}/{{ item.all_number   }}</p>
                <el-progress :percentage="Math.ceil(item.exist_number/item.all_number*100)" class="w-50" />
              </div>
              <button v-if="item.admin_id==user_id" @click="setProjectNotShow(item.project_id)"
               class="btn btn-outline-primary  ml-120 mt-80" style="position: absolute;">
                  删除</button>
          </div>
        </el-carousel-item>
      </el-carousel>
      <RouterView></RouterView>

    </el-tab-pane>
  </el-tabs>
</template>
<script  setup>
import axios from 'axios';
import { ref,reactive, watch,computed} from 'vue'
import {  useRoute,useRouter } from 'vue-router';
import moment from 'moment';
import { ElMessage, ElMessageBox } from 'element-plus'
import { useChatwebsocketStore } from '@/store/chatwebsocket';

const teacher_name=sessionStorage.getItem("user_name")
const activeName = ref('first')
const route=useRoute()
const router=useRouter()
const drawer=ref(false)
let college=route.query.college
let user_id=route.query.user_id
let user_name=sessionStorage.getItem("user_name")
let dialogMessage=ref({})
let dialogMessageStu=ref({})
let dialogProStu=ref({})
let inputMessage=ref("")
let message=reactive({
  message_id:"",
  sender_id:user_id,  
  send_time:"",
  receiver_id:"",
  content:"",
  system:false,
  watch:false,
  sender_name:user_name,
  online:false
})


let teacherList=ref([])
const getTeacherList=async()=>{
  let result=await axios({
    method:"get",
    url:"http://localhost:8080/getTeachersByCollege",
    params:{
      college:college
    }
  })
  return result.data
}
teacherList.value=await getTeacherList()

let studentList=ref([])
const getStudentList=async()=>{
  let result=await axios({
    method:"get",
    url:"http://localhost:8080/getStudentsByCollege",
    params:{
      college:college
    }
  })
  return result.data
}
studentList.value=await getStudentList()

//根据传进来的ID判断是不是本人发送的消息
function isSelf(id){
  if(id==user_id){
    return "row-col-1 mt-1 d-flex flex-row-reverse"
  }
  else{
    return "row-col-1 mt-1 d-flex"
  }
}
const websocketStore=useChatwebsocketStore()
//点开界面之后，自动建立websocket连接
const getconnection=async()=>{
  websocketStore.changeIsClear()
  let ws=new WebSocket("ws://localhost:8080/message/"+user_id);
  return ws
}
let ws=await getconnection()
let receiverId=ref("")
//消息列表
let messageList=ref({})
//得到聊天框
function getChatWindow(receiver_id,name){
  messageList.value[name]=[]
  dialogMessage.value[name]=true
  receiverId.value=receiver_id
}

function getChatWindStu(receiver_id,name){
  messageList.value[name]=[]
  dialogMessageStu.value[name]=true
  receiverId.value=receiver_id
}

function getChatWindPro(receiver_id,name){
  messageList.value[name]=[]
  dialogProStu.value[name]=true
  receiverId.value=receiver_id
}


ws.onmessage=function(evt){
  //告知全局，数据库数据变化
  websocketStore.changeIsConnected()
  //将消息JSON化存入pinia中
  websocketStore.setMessage(JSON.parse(evt.data))
  let tempMess=JSON.parse(evt.data)
  if(tempMess.sender_id==receiverId.value && tempMess.receiver_id==user_id){
    messageList.value[tempMess.sender_name].push(JSON.parse(evt.data))
  }
}
//发送按钮绑定发送消息的功能：将message对象JSON化
function sendMessageToService(receiver_id,receiver_name){
  //设置消息的接受者
  message.receiver_id=receiver_id
  message.receiver_name=receiver_name
  message.sender_name=user_name
  message.send_time=moment().format('YYYY-MM-DD HH:mm:ss')
  //将用户输入的消息放进message中
  message.content=inputMessage.value
  ws.send(JSON.stringify(message))
  message.send_time=moment().format('YYYY-MM-DD HH:mm:ss')
  messageList.value[receiver_name].push(JSON.parse(JSON.stringify(message)))
  inputMessage.value=""
}
function setDialog(name){
  dialogMessage.value[name]=false
}
function setDialogStu(name){
  dialogMessageStu.value[name]=false
}
function setDialogPro(name){
  dialogProStu.value[name]=false
}
watch(route,()=>{
  let projectPath=route.fullPath.split('?')[0]
  let projectQuery=route.query
  router.push({path:'/index/jump',query:{user_id:user_id}})
  if(college!==projectQuery.college){
    setTimeout(() => {
      router.push({path:projectPath,query:projectQuery})
    }, 0.001);
  }
  
})

//科创项目
//根据学院获取该学院的所有大创信息
const getProjectByCollege=async()=>{
  let result=await axios({
    method:"get",
    url:"http://localhost:8080/getProjectByCollege",
    params:{
      college:college
    }
  })
  //遍历将不需要显示的科创项目删除
  for(let i=0;i<result.data.length;i++){
    if(!result.data[i].watch){
      result.data.splice(i,1)
    }
  }
  return result.data
}
let projectList=ref(await getProjectByCollege())

//根据老师的ID获取这个老师管理的所有科创项目
let teacherAdminProjects=ref([])

const getProjectByAdminID=async ()=>{
  let result =await axios({
    method:"get",
    url:"http://localhost:8080/getProjectsByAdminID",
    params:{
      admin_id:user_id
    }
  })
  return result.data
}
teacherAdminProjects.value=await getProjectByAdminID()
console.log(teacherAdminProjects.value)
let applicationList=ref([])//申请列表
let showApplicationList=ref([])
let project_id=ref("")
let projectName=ref("学生列表")
//根据项目的ID获取申请列表
async function getApplicationByProjectID(id,name){
  projectName.value=name
  project_id.value=id
  let result =await axios({
    method:"get",
    url:"http://localhost:8080/getApplicationByProjectID",
    params:{
      project_id:id
    }
  })
  applicationList.value=result.data
  showApplicationList.value=JSON.parse(JSON.stringify(applicationList.value))
  console.log(result.data)
  return result.data
}
//得到状态为同意的申请列表
function getHaveJoinList(){
  //先把显示列表清空
  showApplicationList.value.splice(0,showApplicationList.value.length)
  //遍历ApplicationList选择出已经同意的
  for(let i=0;i<applicationList.value.length;i++){
    console.log(applicationList.value[i])
    if(applicationList.value[i].apply_state=='同意'){
      showApplicationList.value.push(applicationList.value[i])
    }
  }
}

//得到状态为申请中的申请列表
function getApplyList(){
  //先把显示列表清空
  showApplicationList.value.splice(0,showApplicationList.value.length)
  //遍历ApplicationList选择出已经同意的
  for(let i=0;i<applicationList.value.length;i++){
    console.log(applicationList.value[i])
    if(applicationList.value[i].apply_state=='申请中'){
      showApplicationList.value.push(applicationList.value[i])
    }
  }
}
//根据applicationID修改申请的状态为：同意
async function updateApplyState(applicationID,project_id){
  let result=await axios({
    method:"get",
    url:"http://localhost:8080/updateApplicationStateByApplicationID",
    params:{
      application_id:applicationID
    }
  })
  if(result.data){
    ElMessage({
      type: 'success',
      message:"批准成功"
    })
    await getApplicationByProjectID(project_id)
    getApplyList()

  }
}

//添加科创项目
let dialogFormVisible=ref(false)
const formLabelWidth = '68px'
let startTime=reactive({
  date1:"",
  date2:""
})
let endTime=reactive({
  date1:"",
  date2:""
})
let project=reactive({
  project_id:"",
  project_name:"",
  college:college,
  start_time:computed(()=>{
    return startTime.date1+" "+startTime.date2
  }),
  introduce:"",
  project_type:"",
  end_time:computed(()=>{
    return endTime.date1+" "+endTime.date2
  }),
  admin_id:user_id,
  admin_name:sessionStorage.getItem("user_name"),
  exist_number:0,
  all_number:"",
  requirement:"",
  watch:true
})

async function addProject(){
  if(project.project_name && project.project_type && project.start_time &&
   project.end_time && project.introduce && project.all_number && project.requirement){
    //先判断时间是否合法
    if(moment(project.start_time).isAfter(project.end_time)){
      //告知用户时间书写错误
      ElMessage({
        type:"warning",
        message:"时间填写有误，请重新输入"
      })
      return false
    }
    let result=await axios.post("http://localhost:8080/addProject",project)
    if(result.data){
      dialogFormVisible.value=false
      ElMessage({
        type:'success',
        message:"提交成功"
      })
    //更新界面
    projectList.value=await getProjectByCollege()
    teacherAdminProjects.value=await getProjectByAdminID()
    }else{
      ElMessage({
        type:"error",
        message:"出错啦，请稍后重试!"
      })
    }
   }
   else{
    ElMessage({
      type:'warning',
      message:"请完善信息后再提交"
    })
   }
}

//根据project_id删除一个project
async function deleteProject(project_id){
  console.log(project_id)
  let result =await axios({
    method:"get",
    url:"http://localhost:8080/deleteProject",
    params:{
      project_id:project_id
    }
  })
  if(result.data){
    ElMessage({
      type:"success",
      message:"项目结束成功"
    })
    //更新列表
    projectList.value=await getProjectByCollege()
    teacherAdminProjects.value=await getProjectByAdminID()
  }else{
    ElMessage({
      type:"error",
      message:"出错啦！"
    })
  }
}

async function setProjectNotShow(project_id){
  let result =await axios({
    method:"get",
    url:"http://localhost:8080/setProjectNotShow",
    params:{
      project_id:project_id
    }
  })
  if(result.data){
    ElMessage({
      type:"success",
      message:"不可见设置成功"
    })
    //更新列表
    projectList.value=await getProjectByCollege()
  }else{
    ElMessage({
      type:"error",
      message:"出错啦！"
    })
  }
}
//显示学生的信息
const studentInfoShow=ref(false)

//得到学生的信息
let student=ref({
  student_id:"",
  student_name:"",
  student_sex:"",
  college:"",
  major:"",
  interest:"",
  search_exper:""
})
async function getStudentInfoByStudentID(student_id){
  studentInfoShow.value=true
  let result=await axios({
        method:'get',
        url:"http://localhost:8080/getStuById",
        params:{
          student_id:student_id
        }
      })
    student.value=result.data
}


</script>


<style>
.demo-tabs > .el-tabs__content {
  padding:20px 0;
}
.el-carousel__item h3 {
  color: #475669;
  opacity: 0.75;
  line-height: 80px;
  margin: 0;
  text-align: center;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
.demo-progress .el-progress--line {
  margin-bottom: 15px;
  max-width: 600px;
}
</style>

